package com.dailywork.basepro.security.messagedigist;

import lombok.SneakyThrows;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.MessageDigest;
import java.util.Arrays;

/**
 * 消息摘要
 *
 * @author think
 * @version 1.0.0
 * @since 2020/4/4
 */
public class MessageDigistPro {
    @SneakyThrows
    public static void main(String[] args) {
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
        String path = System.getProperty("user.dir");
        path = path.concat(File.separator).concat("dir").concat(File.separator).concat("dx.properties");
        byte[] input = Files.readAllBytes(Paths.get(path));

        System.out.println(Arrays.toString(input));
        byte[] hash = messageDigest.digest(input);
        System.out.println(Arrays.toString(hash));

        messageDigest = MessageDigest.getInstance("MD5");
        byte[] md5 = messageDigest.digest(input);
        System.out.println(Arrays.toString(md5));
    }
}
